<?php
/*
 * @Author: 李志刚
 * @CopyRight: 2020-2030 衡水山木枝技术服务有限公司
 * @Date: 2021-10-19 10:40:03
 * @Description: 优惠券 -- 平台发/门店发 -- 如果平台发放，金额要抵用到每个订单 -- 自领（用户级别限制）/生日/节日（充值送/买会员送--暂无），可以限品类
 * @LastEditors: 李志刚
 * @LastEditTime: 2021-10-20 10:31:46
 * @FilePath: /qingshanERP/database/migrations/b2b/expand/2021_10_19_104003_create_coupon.php
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCoupon extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupons', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->id();
            $table->foreignId('shop_id')->default(0)->comment('门店ID');
            $table->string('title')->comment('优惠券名称');
            $table->tinyInteger('type')->default(0)->comment('类型 1满减 2金额优惠券 3折扣优惠券');
            $table->tinyInteger('source')->default(0)->comment('发放途径 1直接领取 2生日券 3节日 4充值卡');
            $table->unsignedDecimal('price')->default(0)->comment('减免金额');
            $table->unsignedDecimal('base_price')->default(0)->comment('需满足金额');
            $table->unsignedInteger('discount')->default(0)->comment('折扣');
            $table->unsignedInteger('valid_days')->default(0)->comment('有效期（天）');
            $table->integer('num')->default(0)->comment('一次发送数量');
            $table->dateTime('lasttime')->default('2021-10-10 00:00:00')->comment('上架时间');
            $table->dateTime('lowertime')->default('2021-10-10 00:00:00')->comment('下架时间');
            // 下边是规则相关的
            $table->date('holiday')->nullable()->comment('节日');
            $table->unsignedInteger('level_id')->default(0)->comment('对应用户等级id，0为不限制');
            $table->unsignedInteger('recharge_card_id')->default(0)->comment('充值卡ID');
            $table->boolean('status')->default(1)->comment('状态 1正常 0禁用');
            $table->tinyInteger('del_flag')->default(0)->comment('删除状态（1删除 0正常）');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupons');
    }
}
